from django.contrib import admin
from django.contrib.admin.options import get_content_type_for_model
from django.contrib.admin.models import LogEntry

from apps.Info.models import InfoModels
from django.contrib.auth.models import User


@admin.register(InfoModels)
class InfoModelsAdmin(admin.ModelAdmin):
    ordering = ["-create_time"]
    fields = ("TitleInfo", "TextInfo", "ChangeInfo", "Successfully_Info")
    list_display = ("TitleInfo", "TextInfo", "ChangeInfo", "Successfully_Info", "create_time")
    list_filter = ("TitleInfo", "TextInfo", "ChangeInfo", "Successfully_Info")
    search_fields = ("TitleInfo", "TextInfo", "ChangeInfo", "Successfully_Info")
    date_hierarchy = 'create_time'


@admin.register(LogEntry)
class LogEntryAdmin(admin.ModelAdmin):
    list_display = (
        '__str__', 'action_time', 'user', 'content_type', 'object_id', 'object_repr', 'action_flag', 'change_message')
    list_filter = ('content_type',)
    search_fields = ['user__username', ]
    date_hierarchy = 'action_time'
